<?php include "../public/header.php";?>
<?php include "../public/header_show.php";?>
<body id="xiangqingPage">
<div id="xiangqingBox">
    <div class="page-title">
        <div class="page-title-con">
            <span class="pageshowtitle">详情</span>
            <div class="page-title-opt-list">
                <?php include "../public_flow/flow_show_optbut.php";?>
                <button class="layui-btn layui-btn-sm btn-light marginr5 opt">
                    操作<i class="layui-icon layui-icon-down layui-font-12"></i>
                </button>
                <span id="page-close" class="page-close" onclick="layer_close()">×</span>
            </div>
        </div>
    </div>
    <div class="main-container" style="padding-bottom: 100px">
        <div class="table-box tablenes">
            <div class="title">项目信息</div>
            <table class="layui-table">
                <tbody>
                <tr>
                    <td class="tt">项目名称</td><td class="tv colorlan" id="name"></td>
                    <td class="tt">项目编号</td><td class="tv" id="number"></td>
                    <td class="tt">项目状态</td><td class="tv" id="state_name"></td>
                </tr>
                <tr>
                    <td class="tt">联营方/委托方</td><td class="tv" id="lian_unit"></td>
                    <td class="tt">项目所在地</td><td class="tv" id="areas"></td>
                    <td class="tt">项目所属单位</td><td class="tv" id="chanid_name"></td>
                </tr>
                <tr>
                    <td class="tt">中标单位</td><td class="tv" id="winunit_name"></td>
                    <td class="tt">中标日期</td><td class="tv" id="windt"></td>
                    <td class="tt">合同金额含税(元)</td><td class="tv" id="shimoney"></td>
                </tr>
                <tr>
                    <td class="tt">合同税率(%)</td><td class="tv" id="shirate"></td>
                    <td class="tt">管理费费率(%)</td><td class="tv" id="lian_guanrate"></td>
                    <td class="tt">税费费率(%)</td><td class="tv" id="lian_shuirate"></td>
                </tr>
                </tbody>
            </table>
        </div>

        <div class="table-box tablenes">
            <div class="title">数据汇总</div>
            <table class="layui-table">
                <tbody>
                <tr>
                    <td class="tt">项目收入</td>
                    <td class="tv">工程回款金额(元)</td><td class="tv" id="shougonghuifee"></td>
                    <td class="tv">联营方备用金金额(元)</td><td class="tv" id="shoulianbeifee"></td>
                    <td class="tv"><b>收入合计(元)</b></td><td class="tv" id="lianyingshoufee"></td>
                    <td class="tv"></td><td class="tv"></td>
                </tr>
                <tr>
                    <td class="tt">项目支出</td>
                    <td class="tv">项目付款金额(元)</td><td class="tv" id="zhixiangfee"></td>
                    <td class="tv">联营结算金额(元)</td><td class="tv" id="zhilianjiefee"></td>
                    <td class="tv"><b>支出合计(元)</b></td><td class="tv" id="lianyingzhifee"></td>
                    <td class="tv"></td><td class="tv"></td>
                </tr>
                <tr>
                    <td class="tt">扣收费用</td>
                    <td class="tv">已扣管理费(元)</td><td class="tv" id="kou_guanfee"></td>
                    <td class="tv">已扣税费(元)</td><td class="tv" id="kou_shuifee"></td>
                    <td class="tv">其他扣收金额(元)</td><td class="tv" id="kou_qifee"></td>
                    <td class="tv"><b>扣收合计(元)</b></td><td class="tv" id="kou_allfee"></td>
                </tr>
                <tr>
                    <td class="tt"><b>项目资金余额</b></td>
                    <td class="tv" colspan="8">
                        <span id="balancefee"></span>
                        <span style="float: right;color:#999;">(资金余额 = 收入合计 - 支出合计 - 扣收合计)</span>
                    </td>
                </tr>
                <tr>
                    <td class="tt" rowspan="2">项目票税</td>
                    <td class="tv">项目开票金额(元)</td><td class="tv" id="kai_money"></td>
                    <td class="tv">销项税额(元)</td><td class="tv" id="kai_ratefee"></td>
                    <td class="tv">应扣税费(元)</td><td class="tv" id="lian_shuifee"></td>
                    <td class="tv"></td><td class="tv"></td>
                </tr>
                <tr>
                    <td class="tv">项目收票金额(元)</td><td class="tv" id="shou_money"></td>
                    <td class="tv">进项税额(元)</td><td class="tv" id="shou_ratefee_zhuan"></td>
                    <td class="tv">进项退税金额(元)</td><td class="tv" id="zhijintuifee"></td>
                    <td class="tv"></td><td class="tv"></td>
                </tr>
                </tbody>
            </table>
        </div>


        <div class="table-box tablenes">
            <div class="title">工程回款</div>
            <table class="layui-table">
                <tbody>
                <tr>
                    <td class="tt" style="width: 10px!important;">序号</td>
                    <td class="tt">发包方（甲方）</td>
                    <td class="tt">收入合同金额含补充(元)</td>
                    <td class="tt">收入合同结算金额(元)</td>
                    <td class="tt">工程回款金额(元)</td>
                    <td class="tt">项目开票金额(元)</td>
                    <td class="tt">销项税额(元)</td>
                </tr>
                <tr>
                    <td class="tv" style="text-align: right">1</td>
                    <td class="tv" style="text-align: right" id="faer"></td>
                    <td class="tv" style="text-align: right" id="shimoney2"></td>
                    <td class="tv" style="text-align: right" id="shijiemoney"></td>
                    <td class="tv" style="text-align: right" id="shougonghuifee2"></td>
                    <td class="tv" style="text-align: right" id="kai_money2"></td>
                    <td class="tv" style="text-align: right" id="kai_ratefee2"></td>
                </tr>
                </tbody>
            </table>
        </div>


        <div class="table-box tablenes">
            <script type="text/html" id="toolbarDemo_gongfulist">供应商付款</script>
            <div class="tableShow">
                <table id="datalist_gongfulist" lay-filter="datalist_gongfulist"></table>
            </div>
        </div>

        <div class="table-box tablenes">
            <script type="text/html" id="toolbarDemo_shouxiang">联营方来款清单</script>
            <div class="tableShow">
                <table id="datalist_shouxiang" lay-filter="datalist_shouxiang"></table>
            </div>
        </div>


        <div class="table-box tablenes">
            <script type="text/html" id="toolbarDemo_zhilianjie">结算支付清单</script>
            <div class="tableShow">
                <table id="datalist_zhilianjie" lay-filter="datalist_zhilianjie"></table>
            </div>
        </div>
    </div>

</div>
<script>
    var param_id = getQueryVariable('id') || 0;

    layui.use(['form', 'layer', "laytp",'element','dropdown','laypage','table','soulTable'], function() {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable,element = layui.element;

        facade.ajax({url: ask_huizong_show, data:{id: param_id}}).done(function(res){
            if (res.code === 2000) {
                var data = res.data.data;
                var shiinfo = res.data.shiinfo;

                $("#name").text(data.name).click(function () {
                    openPage('../engin/show.php?id='+data.id);
                });
                $("#number").text(data.number);
                $("#state_name").text(data.state_name);
                $("#lian_unit").text(data.lian_unit);
                $("#areas").text(data.areas);
                $("#chanid_name").text(data.chanid_name);
                $("#winunit_name").text(data.winunit_name);
                $("#windt").text(data.windt);
                $("#shimoney").text(parseFormatNum(data.shimoney));
                if(shiinfo){
                    $("#shirate").text(shiinfo.rate);
                }
                $("#lian_guanrate").text(data.lian_guanrate);
                $("#lian_shuirate").text(data.lian_shuirate);


                
                
                $("#shougonghuifee").text(parseFormatNum(data.shougonghuifee)).addClass('colorlan').click(function () {
                    openNavPage('查看项目收款信息','shou_xiang/index.php?status=1&feilei_option=xmsr_gchk&enginid='+data.id);
                });
                $("#shoulianbeifee").text(parseFormatNum(data.shoulianbeifee)).addClass('colorlan').click(function () {
                    openNavPage('查看项目收款信息','shou_xiang/index.php?status=1&feilei_option=xmsr_lyfbyj&enginid='+data.id);
                });
                $("#lianyingshoufee").text(parseFormatNum(data.lianyingshoufee));
                $("#zhixiangfee").text(parseFormatNum(data.zhixiangfee)).addClass('colorlan').click(function () {
                    openNavPage('查看项目付款信息','zhi_xiang/index.php?status=1&enginid='+data.id);
                });
                $("#zhilianjiefee").text(parseFormatNum(data.zhilianjiefee)).addClass('colorlan').click(function () {
                    openNavPage('查看联营结算信息','zhi_lianjie/index.php?status=1&enginid='+data.id);
                });
                $("#lianyingzhifee").text(parseFormatNum(data.lianyingzhifee));
                $("#kou_guanfee").text(parseFormatNum(data.kou_guanfee)).addClass('colorlan').click(function () {
                    openNavPage('查看费用扣收信息','lian_koulan/index.php?status=1&feitype_option=xmsr_lyfyhks_glf&enginid='+data.id);
                });
                $("#kou_shuifee").text(parseFormatNum(data.kou_shuifee)).addClass('colorlan').click(function () {
                    openNavPage('查看费用扣收信息','lian_koulan/index.php?status=1&feitype_option=xmsr_lyfyhks_sf&enginid='+data.id);
                });
                $("#kou_qifee").text(parseFormatNum(data.kou_qifee)).addClass('colorlan').click(function () {
                    openNavPage('查看费用扣收信息','lian_koulan/index.php?status=1&feitype_option=noguannoshui&enginid='+data.id);
                });
                $("#kou_allfee").text(parseFormatNum(data.kou_allfee));
                $("#balancefee").text(parseFormatNum(data.balancefee));
                $("#kai_money").text(parseFormatNum(data.kai_money)).addClass('colorlan').click(function () {
                    openNavPage('查看项目开票信息','piao_kai/index.php?status=1&enginid='+data.id);
                });
                $("#kai_ratefee").text(parseFormatNum(data.kai_ratefee)).addClass('colorlan').click(function () {
                    openNavPage('查看项目开票信息','piao_kai/index.php?status=1&enginid='+data.id);
                });
                $("#lian_shuifee").text(parseFormatNum(data.lian_shuifee));
                $("#shou_money").text(parseFormatNum(data.shou_money)).addClass('colorlan').click(function () {
                    openNavPage('查看项目收票信息','piao_shou/index.php?status=1&enginid='+data.id);
                });
                $("#shou_ratefee_zhuan").text(parseFormatNum(data.shou_ratefee_zhuan)).addClass('colorlan').click(function () {
                    openNavPage('查看项目收票明细信息','piao_shou/detail.php?status=1&piaotype=1&enginid='+data.id);
                });
                $("#zhijintuifee").text(parseFormatNum(data.zhijintuifee)).addClass('colorlan').click(function () {
                    openNavPage('查看进项退税信息','zhi_jintui/index.php?status=1&enginid='+data.id);
                });



                if(shiinfo){
                    $("#faer").text(shiinfo.faer);
                }
                $("#shimoney2").text(parseFormatNum(data.shimoney)).addClass('colorlan').click(function () {
                    openNavPage('查看收入合同信息','contract_shi/index.php?status=1&enginid='+data.id);
                });
                $("#shijiemoney").text(parseFormatNum(data.shijiemoney)).addClass('colorlan').click(function () {
                    openNavPage('查看收入合同结算信息','contract_shi_jie/index.php?status=1&isreal=1&enginid='+data.id);
                });
                $("#shougonghuifee2").text(parseFormatNum(data.shougonghuifee)).addClass('colorlan').click(function () {
                    openNavPage('查看项目收款信息','shou_xiang/index.php?status=1&feilei_option=xmsr_gchk&enginid='+data.id);
                });
                $("#kai_money2").text(parseFormatNum(data.kai_money)).addClass('colorlan').click(function () {
                    openNavPage('查看项目开票信息','piao_kai/index.php?status=1&enginid='+data.id);
                });
                $("#kai_ratefee2").text(parseFormatNum(data.kai_ratefee)).addClass('colorlan').click(function () {
                    openNavPage('查看项目开票信息','piao_kai/index.php?status=1&enginid='+data.id);
                });




                var mytable_gongfulist = table.render({
                    elem: "#datalist_gongfulist",data:res.data.gongfulist, toolbar: '#toolbarDemo_gongfulist', page: false
                    ,limit:TabInitShow.limit,soulSort: TabInitShow.soulSort,method: TabInitShow.method, overflow: TabInitShow.overflow
                    ,defaultToolbar: TabInitShow.defaultToolbar,filter: TabInitShow.filter ,text: TabInitShow.text,totalRow: true
                    ,request: TabInitShow.request,response: TabInitShow.response,contextmenu:get_table_contextmenu(soulTable)
                    , cols: [[
                        {type:'numbers',title:'序号',totalRowText: '合计'}
                        ,{field:'gonger',title:'供应商'}
                        ,{field:'caimoney',title:'支出合同金额含变更(元)',totalRow: true,align:'right',event: 'contract_cai',templet: function(d){
                                return '<span class="colorlan">'+parseFormatNum(d.caimoney)+'</span>';
                            }}
                        ,{field:'caijiemoney',title:'支出合同结算(元)',totalRow: true,align:'right',event: 'contract_cai_jie',templet: function(d){
                                return '<span class="colorlan">'+parseFormatNum(d.caijiemoney)+'</span>';
                            }}
                        ,{field:'shou_money',title:'提供成本票(元)',totalRow: true,align:'right',event: 'piao_shou',templet: function(d){
                                return '<span class="colorlan">'+parseFormatNum(d.shou_money)+'</span>';
                            }}
                        ,{field:'zhixiangfee',title:'付款金额(元)',totalRow: true,align:'right',event: 'zhi_xiang',templet: function(d){
                                return '<span class="colorlan">'+parseFormatNum(d.zhixiangfee)+'</span>';
                            }}
                    ]]
                    , done: function (res) {
                        soulTable.render(this);

                        if(data.is_budget){
                            $("#havebudget").removeClass('layui-hide');
                        }
                    }
                });
                table.on('tool(datalist_gongfulist)',function (obj) {
                    var data = obj.data;
                    if(obj.event === 'contract_cai'){
                        openNavPage('查看支出合同信息','contract_cai/index.php?status=1&enginid='+param_id+'&gonger='+encodeURIComponent(data.gonger));
                    }
                    if(obj.event === 'contract_cai_jie'){
                        openNavPage('查看支出合同结算信息','contract_cai_jie/index.php?status=1&enginid='+param_id+'&isreal=1&gonger='+encodeURIComponent(data.gonger));
                    }
                    if(obj.event === 'piao_shou'){
                        openNavPage('查看项目收票信息','piao_shou/detail.php?status=1&enginid='+param_id+'&gonger='+encodeURIComponent(data.gonger));
                    }
                    if(obj.event === 'zhi_xiang'){
                        openNavPage('查看项目付款信息','zhi_xiang/index.php?status=1&enginid='+param_id+'&duier='+encodeURIComponent(data.gonger));
                    }
                });



                var mytable_shouxiang = table.render({
                    elem: "#datalist_shouxiang",data:res.data.shouxiang, toolbar: '#toolbarDemo_shouxiang', page: false
                    ,limit:TabInitShow.limit,soulSort: TabInitShow.soulSort,method: TabInitShow.method, overflow: TabInitShow.overflow
                    ,defaultToolbar: TabInitShow.defaultToolbar,filter: TabInitShow.filter ,text: TabInitShow.text,totalRow: true
                    ,request: TabInitShow.request,response: TabInitShow.response,contextmenu:get_table_contextmenu(soulTable)
                    , cols: [[
                        {type:'numbers',title:'序号',totalRowText: '合计'}
                        ,{field:'number',title:'收款单号',templet: function(d){
                                return '<span class="colorlan" onclick="openPage(\'../shou_xiang/show.php?id='+d.id+'\')">'+d.number+'</span>';
                            }}
                        ,{field: 'feilei_name', title: '款项类型'}
                        ,{field: 'zhai', title: '款项摘要'}
                        ,{field: 'money', title: '到账金额(元)',totalRow: true,align:'right',templet: function(d){return parseFormatNum(d.money);}}
                        ,{field: 'dt', title: '到账日期'}
                        ,{field: 'duier', title: '付款方'}
                        ,{field: 'baner', title: '经办人'}
                    ]]
                    , done: function (res) {
                        soulTable.render(this);
                    }
                });

                var mytable_zhilianjie = table.render({
                    elem: "#datalist_zhilianjie",data:res.data.zhilianjie, toolbar: '#toolbarDemo_zhilianjie', page: false
                    ,limit:TabInitShow.limit,soulSort: TabInitShow.soulSort,method: TabInitShow.method, overflow: TabInitShow.overflow
                    ,defaultToolbar: TabInitShow.defaultToolbar,filter: TabInitShow.filter ,text: TabInitShow.text,totalRow: true
                    ,request: TabInitShow.request,response: TabInitShow.response,contextmenu:get_table_contextmenu(soulTable)
                    , cols: [[
                        {type:'numbers',title:'序号',totalRowText: '合计'}
                        ,{field:'number',title:'结算单号',templet: function(d){
                                return '<span class="colorlan" onclick="openPage(\'../zhi_lianjie/show.php?id='+d.id+'\')">'+d.number+'</span>';
                            }}
                        ,{field: 'feilei_name', title: '款项类型'}
                        ,{field: 'zhai', title: '款项摘要'}
                        ,{field: 'money', title: '本次结算支付金额(元)',totalRow: true,align:'right',templet: function(d){return parseFormatNum(d.money);}}
                        ,{field: 'explain', title: '备注'}
                        ,{field: 'duier', title: '收款方'}
                        ,{field: 'created_at', title: '创建时间'}
                    ]]
                    , done: function (res) {
                        soulTable.render(this);
                    }
                });

                render_from();
            }
        });

        $(".pageshowtitle").text('联营数据汇总');
        showpage_dropopt();
    });



</script>
</body>
</html>




